package com.framework.common.utils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.squareup.okhttp.Response;

import java.util.HashMap;
import java.util.Map;

public class JuheDataApiHelper {

    public static Object verifyBankCard(String bankNo,String strPayWithdrawConfig,String strBankSdkCodes) {
        String url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?cardNo={yourcardNo}&cardBinCheck=true".replace("{yourcardNo}", bankNo);
        String bankCode = "";
        try {
            Response res = HttpUtils.get(url, null, null);
            String str = res.body().string();
            JSONObject jsonObject = JSONObject.parseObject(str);
            if (!jsonObject.containsKey("bank")) {
                return "获取失败";
            }
            bankCode = jsonObject.getString("bank");
        } catch (Exception e) {
            return "获取失败";
        }
        JSONObject jobject=JSONObject.parseObject(strPayWithdrawConfig);
        JSONArray jsonArray =jobject.getJSONArray("list");
        if (!jsonArray.contains(bankCode)) {
            return "暂不支持该银行";
        }
        JSONObject result = new JSONObject();
        JSONObject jsonObject = JSONObject.parseObject(strBankSdkCodes);
        result.put("bankName", jsonObject.getString(bankCode));
        result.put("bankCode", bankCode);
        return result;
    }
}
